package com.joesem.sale.client.logic.workOrder.option.viewModel

import android.app.Application
import android.util.Log
import com.joesem.sale.client.base.BaseViewModel
import com.joesem.sale.client.base.request
import com.joesem.sale.client.base.toast
import com.joesem.sale.client.network.data.CustomerListMode


class OptionViewModel(application: Application) : BaseViewModel(application) {

    fun getCustomerList(keyword: String? = null, isFirstPage: Boolean) {
        request(request = {
            getCustomerList(keyword, isFirstPage)
        }, response = {
            actionIntent(ListIntent(it.data?.filterNotNull() ?: arrayListOf(), isFirstPage))
        }, responseFailed = {
            toast(it.message)
            actionIntent(ListIntent(arrayListOf(), isFirstPage))
        })
    }



    class ListIntent(val data: List<CustomerListMode>, val isFirst: Boolean)
}